package leetcode.median;

import leetcode.base.TreeNode;

/**
 * ClassName: $230_KthSmallest
 * Description:
 * date: 2021-12-08 8:41
 *
 * @author liyifan
 */
public class $230_KthSmallest {
    int res = 0;
    int rank = 0;
    public int kthSmallest(TreeNode root, int k) {
        recur(root, k);
        return res;
    }

    void recur(TreeNode root, int k) {
        if (root == null)
            return;
        recur(root.left, k);
        rank++;
        if (rank == k){
            res = root.val;
            return;
        }
        recur(root.right, k);

    }
}
